package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.service.IuserService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@RestController
public class UserController {
    @Resource
    private IuserService userService;
    @RequestMapping("/list")
    public ModelAndView toList(){
        return  new ModelAndView("list");
    }
    @RequestMapping("/getPage")
    public Map UserByPage(int pageNum,int pageSize,User user){
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("pageSize",pageSize);
        map.put("pageNum",pageNum);
        map.put("user",user);
        Page page = userService.getLikeUsers(map);
        map.put("page",page);
        map.put("totalPages",page.getPages());
        return map;
    }















    public IuserService getUserService() {
        return userService;
    }

    public void setUserService(IuserService userService) {
        this.userService = userService;
    }
}
